import { AxiosPromise } from "axios";
import axios from "../axios";
import Iservice from "./IService";
import UserInfo from "./index";

class Service implements Iservice {
  querytoken(data?: any): AxiosPromise {
    return axios({
      method: "post",
      url: "/api/users/token",
      data,
    });
  }
  query(params?: any): AxiosPromise {
    return axios({
      method: "get",
      url: "/api/users/getuserinfo",
      params,
    });
  }
  login(data: UserInfo): AxiosPromise {
    return axios({
      method: "post",
      url: "/api/users/login",
      data,
      params: {
        timestamp: Date.now(), //加上时间戳以后 接口就不会缓存
      },
    });
  }
  register(data: UserInfo): AxiosPromise {
    return axios({
      method: "post",
      url: "/api/users/register",
      data,
    });
  }
  adduser(data: UserInfo): AxiosPromise {
    return axios({
      method: "post",
      url: "/api/users/adduser",
      data,
    });
  }
  getuserinfos(params?: any): AxiosPromise {
    return axios({
      method: "get",
      url: "/api/users/getuserinfo",
      params,
    });
  }
  //   del(id: number): AxiosPromise {
  //     return axios({
  //       method: "delete",
  //       url: "/userinfos/" + id,
  //     });
  //   }
}
export default new Service();
